/*-------------------------------------------------------------------------
 - Copyright (c) 2024-2025 [XD-AMCC TEAM]
 - [XD-AMCC] is licensed under Mulan PSL v2.
 - You can use this software according to the terms and conditions of the Mulan PSL v2.
 - You may obtain a copy of Mulan PSL v2 at:
 -          http://license.coscl.org.cn/MulanPSL2
 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
 - OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 - TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 - See the Mulan PSL v2 for more details.
 ------------------------------------------------------------------------*/

/**
 * @brief Interface for the manager for temporary variables and labels.
 *
 * @author  WXQ#XDU
 * @date    2025.01
 */

#pragma once

#ifndef AMCC__TEMPMGR_H
#define AMCC__TEMPMGR_H

#include "../../include/amcc_stack.h"

AMCC_DECL_BEGIN


/**
 * ID type of temporary variables
 */
typedef unsigned int  t_tempvar_id;


/**
 * Class tempmgr, a manager for temporary variables and inner labels.
 */
typedef struct  temp_manager {
    t_stack_ptr  functionStack;  // pass from emitter
    unsigned int varCounter;     // counter of all temp-var
} t_tempmgr, * t_tempmgr_ptr ;



/**
 * @brief Creates and initializes a new manager for temporary variables.
 *
 * @param emitterPtr  pointer to the emitter
 */
extern t_tempmgr_ptr tempmgr_new(t_emitter_ptr emitterPtr);

/**
 * @brief Destroy the manager for temporary variables.
 * @param pThis    pointer to this manager
 */
extern void tempmgr_destroy(t_tempmgr_ptr  pThis);

/**
 * @brief Creates a new temporary variable.
 * @param pThis  pointer to this manager for temporary variables
 * @return the  id for the new temporary variable.
 */
extern t_tempvar_id tempmgr_newTemp(t_tempmgr_ptr  pThis);


AMCC_DECL_END

#endif //AMCC__TEMPMGR_H
